home *** CD-ROM | disk | FTP | other *** search
- /*********************************
- * *
- * Visual Shell v1.17 10/92 *
- * *
- * by Torsten Jürgeleit *
- * *
- * variables *
- * *
- *********************************/
-
- /* Includes */
-
- #include "includes.h"
-
- /* Globals */
-
- struct ArpBase *ArpBase;
- struct GfxBase *GfxBase;
- struct IntuitionBase *IntuitionBase;
- struct Process *_parent_proc;
- struct Device *con_device;
- struct ConUnit *con_unit;
- struct Window *con_window;
- struct RastPort *con_rport;
- struct FileHandle *con_input_fhandle;
- struct FileHandle *con_output_fhandle;
- struct TextFont *con_font;
- struct Task *main_task;
- struct MsgPort *vsh_port;
- struct CommandLineInterface *save_cli;
- struct IOStdReq *input_req;
- struct Interrupt interrupt;
- struct FileRequest file_req[2];
- struct ViewRequest view_req;
- struct HistoryRequest history_req;
- struct TreeRequest tree_req;
- struct FileInfoBlock *fib;
- struct InfoData *idata;
- struct TextFont *old_wb_font;
- struct Gadget gadget;
- struct IntuiText gadget_text;
- struct StringInfo gadget_info;
- struct DateTime date_time;
-
- struct TextAttr con_font_attr, topaz80 = { (STRPTR)"topaz.font",
- TOPAZ_EIGHTY, FS_NORMAL, FPF_ROMFONT };
- struct ConfigEntry config_entry[MAX_CONFIG_ENTRIES] = {
- { "Left edge (0..n)", LONGINT, 4, 0, 0 },
- { "Top edge (0..n)", LONGINT, 4, 0, 0 },
- { "Width (640..n)", LONGINT, 4, MIN_VSH_WIDTH, 0 },
- { "Height (200..n)", LONGINT, 4, MIN_VSH_HEIGHT, 0 },
- { "Number of CLI lines (1..n)", LONGINT, 2, 1, 0 },
- { "Scroll speed (1..3)", LONGINT, 1, 1, 3 },
- { "Keyboard type (1..2)", LONGINT, 1, 1, 2 },
- { "Dump mode (1..3)", LONGINT, 1, 1, 3 },
- { "Path for editor (e.g. c:ED)", 0, MAX_EDITOR_NAME_LEN, 0, 0 },
- { "Options for editor (e.g. STICKY)", 0, MAX_EDITOR_OPTS_LEN, 0, }
- };
- UBYTE special_chars[MAX_SPECIAL_CHARS][8] = {
- { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00 }, /* char 128 */
- { 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c }, /* char 129 */
- { 0x00, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x3c, 0x3c }, /* char 130 */
- { 0x3c, 0x3c, 0x3c, 0x3f, 0x3f, 0x3c, 0x3c, 0x3c }, /* char 131 */
- { 0x3c, 0x3c, 0x3c, 0x3f, 0x3f, 0x00, 0x00, 0x00 } /* char 132 */
- };
- BYTE *fkey_text[MAX_FKEY_MODES - 1][MAX_FKEYS] = {
- { " ", " ", " ", " ", " ", " ", " ",
- " ", " ", " " }, /* mode : none */
-
- { "Hide ", "DupReq", "View ", "Edit ", "Copy ", "RenMov", "MkDir ",
- "Delete", "Histry", "Quit " }, /* mode : normal */
-
- { "DevAsn", "Info ", "QView ", "Find ", "Tree ", "Pattrn", "CmpDir",
- " ", " ", " " }, /* mode : shift down normal */
-
- { "Normal", "Info ", "QView ", "Find ", "Tree ", "Pattrn", "CmpDir",
- " ", " ", " " }, /* mode : shift down devicess & assign */
-
- { "DevAsn", "Normal", "QView ", "Find ", "Tree ", "Pattrn", "CmpDir",
- " ", " ", " " }, /* mode : shift down info */
-
- { "DevAsn", "Info ", "Normal", "Find ", "Tree ", "Pattrn", "CmpDir",
- " ", " ", " " }, /* mode : shift down quick view */
-
- { "DevAsn", "Info ", "QView ", "Normal", "Tree ", "Pattrn", "CmpDir",
- " ", " ", " " }, /* mode : shift down find */
-
- { "Show ", " ", " ", " ", " ", " ", " ",
- " ", " ", "Quit " }, /* mode : hidden */
-
- { " ", " ", " ", " ", " ", " ", " ",
- " ", " ", "Quit " }, /* mode : quit only */
-
- { "Jump ", "Search", "Cont ", "Hex ", "PrtPg ", "PrtAll", " ",
- " ", " ", "Quit " }, /* mode : view ascii */
-
- { "Jump ", "Search", "Cont ", "ASCII ", "PrtPg ", "PrtAll", " ",
- " ", " ", "Quit " }, /* mode : view hex */
-
- { "Jump ", "Search", "Cont ", "PrtPg ", "PrtAll", " ", " ",
- " ", " ", "Quit " }, /* mode : history */
-
- { "Load ", "Save ", "Dfault", "Use ", " ", " ", " ",
- " ", " ", "Quit " }, /* mode : config */
- };
- USHORT key_table[] = { /* raw key codes */
- /* qualifier keys */
- 0x60, /* left shift */
- 0x61, /* right shift */
- 0x63, /* ctrl */
- 0x64, /* left alt */
- 0x65, /* right alt */
- 0x66, /* left amiga */
- 0x67, /* right amiga */
- /* normal keys */
- 0x50, /* f1 */
- 0x51, /* f2 */
- 0x52, /* f3 */
- 0x53, /* f4 */
- 0x54, /* f5 */
- 0x55, /* f6 */
- 0x56, /* f7 */
- 0x57, /* f8 */
- 0x58, /* f9 */
- 0x59, /* f10 */
- 0x42, /* tab */
- 0x5f, /* help */
- 0x45, /* esc */
- 0x44, /* return */
- 0x0f, /* numeric pad : 0 */
- 0x1d, /* numeric pad : 1 */
- 0x1e, /* numeric pad : 2 */
- 0x1f, /* numeric pad : 3 */
- 0x2d, /* numeric pad : 4 */
- 0x2e, /* numeric pad : 5 */
- 0x2f, /* numeric pad : 6 */
- 0x3d, /* numeric pad : 7 */
- 0x3e, /* numeric pad : 8 */
- 0x3f, /* numeric pad : 9 */
- 0x5a, /* numeric pad : left braket */
- 0x5b, /* numeric pad : right braket */
- 0x5c, /* numeric pad : slash */
- 0x5d, /* numeric pad : asteriks */
- 0x4a, /* numeric pad : minus */
- 0x5e, /* numeric pad : plus */
- 0x43, /* numeric pad : enter */
- 0x3c, /* numeric pad : point */
- };
- UBYTE action_table[] = {
- /* qualifier bits */
- QUALIFIERB_SHIFT,
- QUALIFIERB_SHIFT,
- QUALIFIERB_CTRL,
- QUALIFIERB_ALT,
- QUALIFIERB_ALT,
- QUALIFIERB_AMIGA,
- QUALIFIERB_AMIGA,
- /* action codes */
- VSH_ACTION_F1,
- VSH_ACTION_F2,
- VSH_ACTION_F3,
- VSH_ACTION_F4,
- VSH_ACTION_F5,
- VSH_ACTION_F6,
- VSH_ACTION_F7,
- VSH_ACTION_F8,
- VSH_ACTION_F9,
- VSH_ACTION_F10,
- VSH_ACTION_TAB,
- VSH_ACTION_HELP,
- VSH_ACTION_ESC,
- VSH_ACTION_RETURN,
- VSH_ACTION_NUM_0,
- VSH_ACTION_NUM_1,
- VSH_ACTION_NUM_2,
- VSH_ACTION_NUM_3,
- VSH_ACTION_NUM_4,
- VSH_ACTION_NUM_5,
- VSH_ACTION_NUM_6,
- VSH_ACTION_NUM_7,
- VSH_ACTION_NUM_8,
- VSH_ACTION_NUM_9,
- VSH_ACTION_NUM_LEFT_BRAKET,
- VSH_ACTION_NUM_RIGHT_BRAKET,
- VSH_ACTION_NUM_SLASH,
- VSH_ACTION_NUM_ASTERIKS,
- VSH_ACTION_NUM_MINUS,
- VSH_ACTION_NUM_PLUS,
- VSH_ACTION_NUM_ENTER,
- VSH_ACTION_NUM_POINT,
- };
- UBYTE scroll_flag_table[] = {
- 0x81, /* scroll top */
- 0x82, /* scroll bottom */
- 0x41, /* scroll page up */
- 0x42, /* scroll page down */
- 0x01, /* scroll up */
- 0x02, /* scroll down */
- 0x04, /* scroll left */
- 0x08 /* scroll right */
- };
- BYTE *status_text[] = {
- "Reading directory ...",
- "Duplicating file requester ...",
- "Reading devices and assigns ...",
- "Reading file ...",
- "Building line list ...",
- "Releasing line list ...",
- "Running file ...",
- "Editing file ...",
- "Inserting file name at current cursor position ...",
- "Changing view mode ...",
- "Executing user function ...",
- "Printing text ... (ESC to abort)",
- "Making new directory ...",
- "Releasing directory tree",
- "ConMan command line history",
- "Executing history line ...",
- "Executing script file ...",
- "Comparing directories ..."
- };
- BYTE *error_text[] = {
- "Out of memory !",
- "No directory !",
- "No load file !",
- "Lock() failed !",
- "Open() failed !",
- "Read() failed !",
- "Write() failed !",
- "Seek() failed !",
- "Examine() failed !",
- "ExNext() failed !",
- "ParentDir() failed !",
- "Info() failed !",
- "FindFirst() or FindNext() failed !",
- "SyncRun() failed !",
- "Execute() failed - perhaps no c:Run !",
- "Rename() failed !",
- "CreateDir() failed !",
- "DeleteFile() failed !",
- "SetProtection() failed !",
- "SetComment() failed !",
- "SetDate() failed !",
- "Search failed !",
- "Directory not found !",
- "Can't find CLI !",
- "Only valid for ConMan v1.3 or higher !",
- "Can't access editor !",
- "Editor no load file !",
- "Can't build path name !",
- "Can't open PRT: !",
- "Printing text failed !",
- "Missing second quote in user function !",
- "No file name specified !",
- "Empty file selected !",
- "Can't access source !",
- "Can't access destination !",
- "Object not found !",
- "Object in use !",
- "Object already exists !",
- "Object of wrong type !",
- "Directory name already used by a file!",
- "Disk write protected !",
- "Disk not validated !",
- "Disk full !",
- "No disk in drive !",
- "Not a DOS disk in drive !",
- "Invalid pattern !",
- "Can't copy object onto itself !",
- "Multiple copy only to directory !",
- "Can't rename/move entry onto itself !",
- "Multiple rename/move only to directory !",
- "Can't rename object across devices !",
- "Aborted !",
- "Invalid line number !",
- "Invalid hex number !",
- "Different directory modes !",
- "Read protection flag set !",
- "Write protection flag set !",
- "Execute protection flag set !",
- "Delete protection flag set !",
- NULL, /* no msg for skipped error */
- "Not enough memory for copy buffer !",
- "Directory not empty !"
- };
- BYTE *prompt_line[] = {
- "3Press <ENTER> or <F10> for next page or continue !",
- "3Press <ENTER>, <Shift ENTER> or <F10> for next/previous page or continue !",
- "3Press <Shift ENTER> or <F10> for previous page or continue !",
- "3Press <ENTER> or <F10> to continue !"
- };
- BYTE *about_line[MAX_ABOUT_LINES] = {
- "3Visual Shell (VSh) v1.17",
- (BYTE *)-1L,
- "1© Copyright 1992, Freeware, All rights reserved",
- NULL,
- "1written by Torsten Jürgeleit ",
- "1 Am Sandberg 4 ",
- "1 W-5270 Gummersbach ",
- "1 Germany ",
- "1 Phone ++49 2261 27400",
- NULL,
- "1Thanks to the ARP authors for their great ARP library",
- "1and William S. Hawes for his wonderful ConMan !",
- NULL,
- "1Press HELP for some informations about VSh commands !"
- };
- BYTE *help_line[] = {
- "HDescription of function keys for Main :",
- "3F1 = toggle display mode (Hide = hide file requesters)",
- "3F2 = duplicate active filerequester to nonactive one",
- "3F3 = view selected file as ASCII or hex dump",
- "3F4 = edit selected file",
- "3F5 = copy marked files from active to nonactive file requester",
- "3F6 = move or rename marked files from active to nonactive freq",
- "3F7 = make new directory in active file requester",
- "3F8 = delete marked files from active file requester",
- "3F9 = show ConMan command line history",
- "3F10 = quit VSh",
- "3F11 = show devices, assigns and volumes in active file req",
- "3F12 = show infos about other file requester in active one",
- "3F13 = show contents of selected file in active file requester",
- "3F14 = search file by pattern, start from path in active file req",
- "3F15 = new filter pattern for active file requester",
- "3F16 = build directory tree for device in active file requester",
- "3F17 = compare contents of both file requesters",
- "3ALT F1",
- "4 : = user defined functions",
- "3ALT F10",
- "3ALT SHIFT F1 = change user defined functions, special symbols :",
- "4 : '[]' -> insert selected file name at this position",
- "3ALT SHIFT F10 ';' -> delimiter for function key name (max. 6 chars)",
-
- "HDescription of function keys for View :",
- "3F1 = jump to line specified by number",
- "3F2 = search string in file (hex string with a leading $)",
- "3F3 = continue searching with same search string",
- "3F4 = toggle view mode (ASCII or hex dump)",
- "3F5 = send current page to printer",
- "3F6 = send whole text to printer",
- "3F10 = quit view",
-
- "HDescription of function keys for History :",
- "3F1 = jump to line specified by number",
- "3F2 = search string in history",
- "3F3 = continue searching with same search string",
- "3F4 = send current page to printer",
- "3F5 = send whole history to printer",
- "3F10 = quit history",
-
- "HDescription of function keys for Configuration :",
- "3F1 = load old configuration file 's:VSh.Config'",
- "3F2 = save new configuration file 's:VSh.Config'",
- "3F3 = use default configuration",
- "3F4 = use selected configuration",
- "3F10 = quit configuration",
-
- "HDescription of numeric pad keys :",
- "31 = move cursor in file list to bottom of list",
- "32 = move cursor in file list down by one entry",
- "33 = move cursor in file list down by one page",
- "34 = read parent directory",
- "3SHIFT 4 = read root directory",
- "35 = read current directory once again",
- "36 = read directory under cursor",
- "3SHIFT 6 = read directory under cursor to nonactive file requester",
- "37 = move cursor in file list to top of list",
- "38 = move cursor in file list up by one entry",
- "39 = move cursor in file list up by one page",
- "30 = mark or unmark selected entry in active file requester",
- "3SHIFT 0 = unmark all selected entries",
- "3. = insert file name in command line",
- "3SHIFT . = insert file name with full path in command line",
- "K13- = select entries to mark by pattern (* = mark all)",
- "K23+ = select entries to mark by pattern (* = mark all)",
- "K13SHIFT - = select entries to unmark by pattern (* = unmark all)",
- "K23- = select entries to unmark by pattern (* = unmark all)",
- "K13ALT - = toggle num lock for normal numeric key pad",
- "K23[ = toggle num lock for normal numeric key pad",
- "3ENTER = run file, execute script or enter dir under cursor",
-
- "HDescription of other keys :",
- "3TAB = toggle active file requester",
- "3HELP = show this help pages",
- "3SHIFT HELP = show about page",
- "3SHIFT ALT HELP = change configuration",
- "3ALT [any key] = speed search",
- "3ESC = quit any function",
-
- NULL
- };
-
- BYTE gadget_buffer[MAX_GADGET_BUFFER_LEN + 1],
- day_buffer[LEN_DATSTRING + 1],
- date_buffer[LEN_DATSTRING + 1],
- time_buffer[LEN_DATSTRING + 1];
- BYTE process_name[MAX_PROCESS_NAME_LEN + 1];
- UBYTE *font_data, *template_buffer;
- BYTE *cursor_off = "\x1b[H\x1b[0 p\n", *cursor_on = "\x1b[H\x1b[ p",
- *protection_bits = PROTECTION_BITS, *nil = "NIL:", *star = "*",
- *empty = "";
- BYTE *dir_arg[2], *user_fkey_text[MAX_FKEYS],
- *user_function[MAX_USER_FUNCTIONS];
- BPTR con_handle, nil_handle;
- BYTE path1_buffer[MAX_PATH_NAME_LEN + 1],
- path2_buffer[MAX_PATH_NAME_LEN + 1],
- file1_buffer[MAX_FILE_NAME_LEN + 1],
- file2_buffer[MAX_FILE_NAME_LEN + 1],
- line1_buffer[MAX_LINE_LEN + 1],
- line2_buffer[MAX_LINE_LEN + 1],
- status_fmt[60],
- standard_fmt[6],
- protection_string[MAX_PROTECTION_BITS + 1];
- UBYTE event_mode, action, auto_repeat, active_freq, scroll_flag, show_flag,
- num_lock, qualifier, enable_abort, wshell_flag, delayed_cd;
- SHORT status, status_delay, error_delay;
- UBYTE old_bleft, old_btop, old_bright, old_bbottom;
- USHORT old_left, old_top, old_width, old_height, old_min_width,
- old_min_height, old_max_width, old_max_height;
- ULONG old_flags, old_idcmp_flags;
- USHORT vsh_left, vsh_top, vsh_width, vsh_height, vsh_cli_lines;
- UBYTE vsh_scroll_speed, vsh_keyboard_type, vsh_dump_mode;
- BYTE *vsh_config_file = VSH_CONFIG_FILE, *vsh_editor_name,
- *vsh_editor_opts;
- USHORT wb_width, wb_height, wb_line_len, max_line_len, max_dir_name_len,
- cli_vpos, fkey_dist, fkey_left, last1_answer, last2_answer;
-